﻿@model WeProjects.Models.ProjectMemberListVModel
<style type="text/css">
    fieldset .table {
        margin-top:0 !important;
    }
    select {
        width:120px;
        margin-right:10px;
        height:25px;
        vertical-align:-1px;
    }
    legend {
        padding-bottom:0 !important;
        margin-bottom:0 !important;
    }
</style>
@{
    ViewBag.Title = "Member";
    int usrId = int.Parse(Membership.GetUser().ProviderUserKey.ToString());
    @*不是组长，也不是管理员*@
    //if(Model.OwnerID!=userId && !Roles.IsUserInRole("sysadmin"))
    //{
    //    Response.Write("当前用户没有权限操作");
    //    Response.End();
    //}
}
@Html.Partial("_projectMenu",Model.Project.ID)
<h2>@Model.Project.Title > 项目成员</h2>

@if (Model.Project.OwnerID == usrId || Roles.IsUserInRole("sysadmin"))
{
    using (Html.BeginForm("NewMember", "Project", FormMethod.Post))
    {
        <div class="form-group">
            <span class="control-label width-70p">用户账号</span>@Html.DropDownList("MemberName", String.Empty)
            @Html.Hidden("id", Model.Project.ID) 
            @*用户账号：<input type="hidden" name="id" value="@Html.ViewContext.RouteData.Values["id"]" />
                <input type="text" name="memberName" value="" />*@
            <input type="submit" name="Submit" id="submit" value="新增" class="btn btn-success width-20p" /> @ViewBag.memberErr
        </div>
    }
}
@using(Html.BeginForm("SetOwner","Project",FormMethod.Post))
{
    <div>
        <span class="control-label width-70p">组长账号</span>@Html.DropDownList("OwnerName",new SelectList(Model.Members,"Name","DisplayName",Model.Project.OwnerName))
        @Html.Hidden("projectID",Model.Project.ID)        
        <input type="submit" name="Submit" id="submit" value="设定" class="btn btn-success width-20p" /> @ViewBag.memberErr
    </div>
}
<fieldset class="marginT-15p">
    @if (Model.Members.Count > 0)
    {
        <legend>已有成员：</legend>
        <table class="table">
            <tr><th></th><th></th><th>Name</th><th>DisplyName</th><th>操作</th></tr>
            @{int rowNo = 0;}
            @foreach (var item in Model.Members)
            {
                <tr>
                    <td>@(++rowNo)</td>
                    <td>
                        @if (item.ID == Model.Project.OwnerID)
                        {
                            <b style="color:red">负责人</b>
                        }
                        else
                        {
                            <b>成员</b>
                        }
                    </td>
                    <td>

                        @item.Name
                    </td>
                    <td>@item.DisplayName</td>
                    <td>@*if (item.ID != Model.Project.OwnerID && (Model.Project.OwnerID == usrId || Roles.IsUserInRole("sysadmin")))*@
                        @if (Roles.IsUserInRole("sysadmin"))                           
                        {
                            @Html.ActionLink("移除", "MemberDel","Project", new { memberId = item.ID, projectId = Model.Project.ID }, new { @class = "btn btn-danger btn-small" })}
                    </td>
                </tr>
            }
        </table>
    }
    else
    {
        <b>暂无成员，请先添加。</b>
    }
</fieldset>